package com.xh.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.system.comm.util.JsonUtils;
import com.system.common.pojo.BisCustomUser;
import com.xh.service.BisCustomUser1Service;
import com.xh.service.BisCustomUserService;


@Controller
@RequestMapping("custom1")
public class BisCustomUser1Controller {
    
	@Autowired
	private BisCustomUser1Service bisCustomUser1Service;
	@Autowired
	private BisCustomUserService bisCustomUserService;
	
	@RequestMapping("list")
	public String list(Model model,HttpServletRequest request){
		Map<String,Object> map=mohuQuery(request);
   	    List<Map<String,Object>> customList = bisCustomUser1Service.listAll(map);
   	    model.addAttribute("customList",customList);
		return "/bcujsp/bisCustomUserList1";
	}
	
	private Map<String,Object> mohuQuery(HttpServletRequest request){
   	 Map<String,Object> map=new HashMap<>();
   	 String qmobile=request.getParameter("qmobile");
   	 String qusername=request.getParameter("qusername");
   	 String qborndate=request.getParameter("qborndate");
   	 String qbeautynum=request.getParameter("qbeautynum");
   	 String qbagnum=request.getParameter("qbagnum");
   	 if(qmobile!=null&&!qmobile.equals("")){
   		 map.put("qmobile",qmobile );
   		 request.setAttribute("qmobile", qmobile);
   	 }
   	 if(qusername!=null&&!qusername.equals("")){
   		 map.put("qusername", qusername);
   		 request.setAttribute("qusername", qusername);
   	 }
   	 if(qborndate!=null&&!qborndate.equals("")){
   		 map.put("qborndate",qborndate );
   		 request.setAttribute("qborndate",qborndate );
   	 }
   	 if(qbeautynum!=null&&!qbeautynum.equals("")){
  		 map.put("qbeautynum",qbeautynum );
  		 request.setAttribute("qbeautynum",qbeautynum );
  	 }
   	 if(qbagnum!=null&&!qbagnum.equals("")){
 		 map.put("qbagnum",qbagnum );
 		 request.setAttribute("qbagnum",qbagnum);
 	 }
   	 return map;
    }
	@RequestMapping(value="select",produces="application/json;charset=utf-8")
	@ResponseBody
    public String init(String customUserId){
   	 BisCustomUser custom=bisCustomUserService.getById(customUserId);
   	 String cus=JsonUtils.toJson(custom);
   	 return cus;
    }
	@RequestMapping("list1")
	public String list1(Model model,HttpServletRequest request){
		Map<String,Object> map=mohuQuery1(request);
   	    List<Map<String,Object>> customList1 = bisCustomUser1Service.listAll1(map);
   	    model.addAttribute("customList1",customList1);
		return "/bcujsp/bisCustomUserList1";
	}
	private Map<String,Object> mohuQuery1(HttpServletRequest request){
		Map<String,Object> map=new HashMap<>();
		String qorderid=request.getParameter("qorderid");
		String qordercontent=request.getParameter("qordercontent");
		String qpayway=request.getParameter("qpayway");
		if(qorderid!=null&&!qorderid.equals("")){
	 		 map.put("qorderid",qorderid );
	 		 request.setAttribute("qorderid",qorderid);
	 	 }
		if(qordercontent!=null&&!qordercontent.equals("")){
	 		 map.put("qordercontent",qordercontent );
	 		 request.setAttribute("qordercontent",qordercontent);
	 	 }
		if(qpayway!=null&&!qpayway.equals("")){
	 		 map.put("qpayway",qpayway );
	 		 request.setAttribute("qpayway",qpayway);
	 	 }
		return map;
	}
}
